//https://leetcode.cn/problems/merge-sorted-array/?envType=problem-list-v2&envId=ex0k24j
//这个题目比较巧，是因为他把从后面开始填写数字；
#include <vector>
#include <string>
using namespace std;

class Solution {
public:
    void merge(vector<int>& arr1, int m, vector<int>& arr2, int n) {
        
        int i = m - 1, j = n - 1, k = m + n - 1;
        while (i >= 0 && j >= 0) {
        if (arr1[i] > arr2[j]) {
            arr1[k--] = arr1[i--];
        } else {
            arr1[k--] = arr2[j--];
        }
    }
    while (j >= 0) {
        arr1[k--] = arr2[j--];
    }
    }
};